<style lang="scss" scoped>
  @import '../../styles/common/loading.less';
  .container{
    border: none !important;
    margin-top: 4px;
  }
  .el-col-offset-1 {
    margin-left: 0%;
  }
  .button_a {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);

  }
  .col_a {
    margin-left: 2%;
  }
  .el-card {
    height: 200px;
  }
  .el-button--primary {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);
  }
  .input-textarea{
    height: 87px !important
  }
</style>
<template>
    <div>
      <div style="width:98%;height:100%;margin: 6px 12px;">
        <el-collapse v-model="activeNames" @change="handleChange"  >
          <el-collapse-item title="基本信息"  name="1">
            <!-- 基本信息 -->
            <template>
              <el-form :model="formInline" class="info-submit-form">
                <el-row type="flex" >
                  <el-col :span="8"  >
                    <el-form-item label="大病赔案号">
                      <el-input  v-model="formInline.caseNo" disabled></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" >
                    <el-form-item label="保单号" >
                      <el-input v-model="formInline.policyNo" disabled></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" >
                    <el-form-item label="被保险人" >
                      <el-input v-model="formInline.insuredName" disabled></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row type="flex">
                  <el-col :span="8" >
                    <el-form-item label="社/医保号">
                      <el-input v-model="formInline.medicalInsuranceNo" disabled></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" >
                    <el-form-item label="证件类型">
                      <el-input v-model="formInline.documentType" disabled></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" >
                    <el-form-item label="证件号">
                      <el-input v-model="formInline.documentNo" disabled></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row type="flex">
                  <el-col :span="8">
                    <el-form-item label="调查原因" >
                      <el-input v-model="formInline.surveyReason" disabled placeholder="请输入原因"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="原因描述">
                      <el-input v-model="formInline.surveyDescribe" disabled placeholder="请输入原因描述"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row type="flex" class="input-textarea">
                  <el-col :span="24">
                    <el-form-item label="地点描述">
                      <el-input :rows="3" show-word-limit disabled v-model="formInline.addressDesc" type="textarea"  ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row type="flex" class="input-textarea">
                  <el-col :span="24">
                    <el-form-item label="经过">
                      <el-input :rows="3" show-word-limit disabled  v-model="formInline.surveyProcess" type="textarea" ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row type="flex" class="input-textarea">
                  <el-col :span="24">
                    <el-form-item label="描述">
                      <el-input :rows="3" show-word-limit disabled v-model="formInline.surveyRemark" type="textarea"  ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row type="flex" class="input-textarea">
                  <el-col :span="24">
                    <el-form-item label="结论">
                      <el-input :rows="3" show-word-limit disabled v-model="formInline.surveyResult" type="textarea"  ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </template>
          </el-collapse-item>
        </el-collapse>
        <el-collapse  style="margin-top: 10px" v-model="activeNames" @change="handleChange">
          <el-collapse-item title="调查历史轨迹信息"  name="2">
            <!-- 调查轨迹信息 -->
            <template>
              <el-table
                :data="researchHistory"
                class="table"
                ref="multipleTable"
                header-cell-class-name="table-header"
                style="margin: 5px 0;border: 1px solid #d6d9d8;"
              >
                <el-table-column label="大病赔案号" align="center">
                  <template slot-scope="scope" >
                    <a @click="applicant(scope.row)" style="color: #1e99f9;cursor: pointer">{{ scope.row.caseNo }}</a>
                  </template>
                </el-table-column>
                <el-table-column prop="policyNo" label="保单号" align="center"></el-table-column>
                <el-table-column prop="handlerCode" label="调查员工号" align="center"></el-table-column>
                <el-table-column prop="handlerName" label="调查员姓名" align="center"></el-table-column>
                <el-table-column prop="surveyReason" :formatter="surveyReasonFormat" label="调查原因" align="center"></el-table-column>
                <el-table-column prop="surveyResult" label="调查结论" align="center"></el-table-column>
                <el-table-column prop="auditTime" label="调查时间" align="center"></el-table-column>
              </el-table>
            </template>
          </el-collapse-item>
        </el-collapse>
        <el-collapse style="margin-top: 10px" v-if="this.item===1" v-model="activeNames" @change="handleChange"  >
          <el-collapse-item title="审核意见"  name="3">
              <div style="height: 20px;margin-top: 10px;margin-left: 5px">
                <span>审核意见</span>:
                <el-radio v-model="auditOpinion" label="03" style="margin-left: 20px">同意</el-radio>
                <el-radio v-model="auditOpinion" label="04">返回</el-radio>
              </div>
              <div style="margin-top: 10px">
                <el-input placeholder="请输入内容" v-model="remark">
                  <template slot="prepend">审核备注</template>
                </el-input>
              </div>
              <div style="margin-top: 20px">
                <el-input placeholder="请输入内容" v-model="evaluate">
                  <template slot="prepend">评价短语</template>
                </el-input>
              </div>
          </el-collapse-item>
        </el-collapse>
        <el-collapse style="margin-top: 10px" v-if="this.item===0" v-model="activeNames" @change="handleChange"  >
          <el-collapse-item title="审核意见"  name="3">
            <div style="height: 20px;margin-top: 10px;margin-left: 5px">
              <span>审核意见</span>:
              <el-radio disabled v-model="auditOpinion" label="03" style="margin-left: 20px">同意</el-radio>
              <el-radio disabled v-model="auditOpinion" label="04">返回</el-radio>
            </div>
            <div style="margin-top: 10px">
              <el-input disabled placeholder="请输入内容" v-model="remark">
                <template slot="prepend">审核备注</template>
              </el-input>
            </div>
            <div style="margin-top: 20px">
              <el-input disabled placeholder="请输入内容" v-model="evaluate">
                <template slot="prepend">评价短语</template>
              </el-input>
            </div>
          </el-collapse-item>
        </el-collapse>
        <div style="margin-top: 25px;text-align: center;height: 70px">
<!--          <el-button type="primary"  @click="onSubmit" style="width: 10%">重置</el-button>-->
			<el-button type="primary" size="medium" @click="imgQueryShow" style="width: 10%">查看单证</el-button>
          <el-button type="primary"  @click="onSubmitResearCheck" style="width: 10%">提交</el-button>
          <el-button type="primary"  @click="ondelete" style="width: 10%">关闭</el-button>
        </div>
      </div>
      <el-dialog
        :visible.sync="Successdialog"
        :show-close="false"
        :close-on-click-modal="true"
        :close-on-press-escape="false"
        width="20%"
        center>
        <div style="margin-top: -35px;">
          <div>| 调查审核提交</div>
          <hr style="width: 80%;margin-left: 1px">
        </div>
        <div v-if="this.item===0" style="text-align: center;margin-top: 20px">
          <img src="../../assets/images/pass.png" width="60">
          <div style="margin-top: 10px">提交成功</div>
          <div style="margin-top: 10px">大病赔案号：{{formInline.caseNo}}</div>
        </div>
        <div v-if="this.item===1" style="text-align: center;margin-top: 20px">
          <img src="../../assets/images/notPass.png" width="60">
          <div style="margin-top: 10px">提交失败</div>
          <div style="margin-top: 10px">大病赔案号：{{formInline.caseNo}}</div>
        </div>
        <div style="margin-top: 15px;text-align: center"><span style="font-size: x-large">{{time}}</span>秒后跳转到上一个页面</div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="researchCheckSearch" type="text" :disabled="isDisabled">关闭</el-button>
        </div>
      </el-dialog>
    </div>
</template>

<script>
  import * as api from '@/api/baseDate'
  import Cookies from "js-cookie";
  export default {
    name: 'researchManage',
    data() {
        return {
          bussNo:'',//单证查看需要的参数
          item:0,
          evaluate:'',
          remark:'',
          auditOpinion:'',
          Successdialog:false,
          Sencond:5,
          isDisabled:false,
          formInline:{},
          activeNames: ['1','2','3'],
          time: 0,
            researchHistory:[{
                policyNo:456431654,
                handler:456431654,
                caseNo:1235465464656,
                submitTime:'2021-01-01',
                surveyPass:'调查中',
                surveyResult:'通过无误',
                surveyVerdict:'可以提交审核',
                surveyCost:'200',
            }],
        };
    },
  created() {
    this.formInline=JSON.parse(this.$route.query.researchCheck)
    if (this.formInline.surveyReason ==='1' ) {
      this.formInline.surveyReason='频繁报销'
    } else if (this.formInline.surveyReason === '2') {
      this.formInline.surveyReason='异地就医'
    } else if (this.formInline.surveyReason === '9') {
      this.formInline.surveyReason='其它'
    }
    this.item=JSON.parse(this.$route.query.item)
    this.getQuerySurveyHistory();
  },
  methods: {
   //查看单证方法
    imgQueryShow(){
       this.bussNo= this.formInline.caseNo;
       if(this.bussNo !== null){
         api.imgQueryShow(this.bussNo).then(res => {
            window.open(res.data.url)
         })
       }else{
           this.$message.error(`请您先检查大病赔案号后，再上传影像资料！`);
       }
    },
    surveyReasonFormat(row, column) {
      let surveyReason = row.surveyReason
      if (surveyReason === '1') {
        return '频繁报销'
      } else if (surveyReason === '2') {
        return '异地就医'
      } else if (surveyReason === '9') {
        return '其它'
      }
    },
    getQuerySurveyHistory(){
      var data={
        "handlerName":this.formInline.handlerName,
      }
      api.getQuerySurveyHistory(data
      ).then(res => {
        this.researchHistory=res.data;
        console.log("历史轨迹"+res)
      })
    },
    applicant(row){
      this.form=row,
        console.log(this.form)
      this.$router.push({
        name: 'historicalRoute',
        query: {
          form: JSON.stringify(this.form),
          formInline: JSON.stringify(this.formInline),
          item: JSON.stringify(this.item),
          its: JSON.stringify(1)
        }
      })
    },
    ondelete(){
      this.$router.go(-1)
    },
    onSubmitResearCheck() {
      // alert(this.auditOpinion)
      var data = {
        "id": this.formInline.id,
        "taskType": this.formInline.taskType,
        "caseNo": this.formInline.caseNo,
        "flowId": this.formInline.flowId,
        "evaluate": this.evaluate,
        "remark": this.remark,
        "auditOpinion": this.auditOpinion,
      }
      api.getAuditCaseSurvey(data
      ).then(res => {
        this.Successdialog=true
        // 把time改为5
        this.time = 5;
        // 设定一个定时器，每一秒调用一次coundDown方法，time-1
        setInterval(this.countDown, 1000);
      }).catch((function () {
        /*let THIS = this;*/
        this.item=1,
          this.Successdialog=true
        // 把time改为5
        this.time = 5;
        // 设定一个定时器，每一秒调用一次coundDown方法，time-1
        setInterval(this.countDown, 1000);
      }),
    )
    },
    researchCheckSearch(){
      // this.Successdialog=false
      this.$router.push({name:'researchCheckSearch'});
    },
//   封装一个方法
    countDown() {
      let THIS = this;
      THIS.time--;
    },
  },
  mounted() {

  },
  watch: {
    //   监听time的值
    time: function (newVal) {
      if (newVal == 0) {
        this.$router.push({name:'researchCheckSearch'});
        // this.Successdialog=false
      }
    },
  },
};
</script>